<!DOCTYPE html>
<html lang="en">

    <head><title>orcale单机安装 &ndash; UxiaoTag的博客</title>
<meta name="description" content="一个蒟蒻无比的萌新.">

<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8"/>



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css" integrity="sha512-1sCRPdkRXhBV2PBLUdRb4tMg1w2YPf37qatUFeS7zlBy7jJI8Lf4VHwWfZZfpXtYSLy85pkm9GaYVYMfw5BC1A==" crossorigin="anonymous" />


<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/academicons/1.9.1/css/academicons.min.css" integrity="sha512-b1ASx0WHgVFL5ZQhTgiPWX+68KjS38Jk87jg7pe+qC7q9YkEtFq0z7xCglv7qGIs/68d3mAp+StfC8WKC5SSAg==" crossorigin="anonymous" />


<link rel="stylesheet" href="https://juruoxiao.gitee.io/linux_work/css/palettes/base16-dark.css">
<link rel="stylesheet" href="https://juruoxiao.gitee.io/linux_work/css/risotto.css">
<link rel="stylesheet" href="https://juruoxiao.gitee.io/linux_work/css/custom.css">
</head>

    <body>
        <div class="page">

            <header class="page__header"><h1 class="page__logo"><a href="https://juruoxiao.gitee.io/linux_work" class="page__logo-inner">UxiaoTag的博客</a></h1>
<nav class="page__nav main-nav">
    <ul>
    
    
    <li class="main-nav__item"><a class="nav-main-item" href="https://juruoxiao.gitee.io/linux_work/about/" title="">About</a></li>
    
    <li class="main-nav__item"><a class="nav-main-item active" href="https://juruoxiao.gitee.io/linux_work/post/" title="Posts">Posts</a></li>
    
    </ul>
</nav>

</header>

            <section class="page__body">
    <header class="content__header">
        <h1>orcale单机安装</h1>
    </header>
    <div class="content__body">
        <p>orcale单机安装全过程</p>
<h1 id="orcale单机安装">orcale单机安装</h1>
<h2 id="1-检查环境">1 检查环境</h2>
<p>通过以下命令检查</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>grep MemTotal /proc/meminfo
</span></span><span style="display:flex;"><span>grep SwapTotal /proc/meminfo
</span></span><span style="display:flex;"><span>df -k /path/to/install
</span></span><span style="display:flex;"><span>grep <span style="color:#e6db74">&#34;model name&#34;</span> /proc/cpuinfo
</span></span></code></pre></div><h2 id="2-安装所需要的包">2 安装所需要的包</h2>
<p>自行检查以下包是否安装</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>rpm --query --queryformat <span style="color:#e6db74">&#34;%{NAME}-%{VERSION}.%{RELEASE} (%{ARCH})\n&#34;</span> bc binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat elfutils-libelf elfutils-libelf-devel fontconfig-devel libxcb smartmontools libX11 libXau libXtst libXrender libXrender-devel
</span></span></code></pre></div><p>自己找个文档，里面有包的需求</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>yum install -y bc <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>binutils <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>compat-libcap1 <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>compat-libstdc++-33 <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>gcc <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>gcc-c++ <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>elfutils-libelf <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>elfutils-libelf-devel <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>glibc <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>glibc-devel <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>ksh <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>libaio <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>libaio-devel <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>libgcc <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>libstdc++ <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>libstdc++-devel <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>libxcb <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>libX11 <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>libXau <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>libXi <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>libXtst <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>libXrender <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>libXrender-devel <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>make <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>net-tools <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>nfs-utils <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>smartmontools <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>sysstat <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>e2fsprogs <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>e2fsprogs-libs <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>fontconfig-devel <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>expect <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>unzip <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>openssh-clients <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>readline* <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>psmisc --skip-broken
</span></span></code></pre></div><h2 id="3-设置内核参数">3 设置内核参数</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>fs.aio-max-nr <span style="color:#f92672">=</span> <span style="color:#ae81ff">1048576</span>
</span></span><span style="display:flex;"><span>fs.file-max <span style="color:#f92672">=</span> <span style="color:#ae81ff">6815744</span>
</span></span><span style="display:flex;"><span>kernel.shmall <span style="color:#f92672">=</span> <span style="color:#ae81ff">16451328</span>
</span></span><span style="display:flex;"><span>kernel.shmmax <span style="color:#f92672">=</span> <span style="color:#ae81ff">33692319744</span>
</span></span><span style="display:flex;"><span>kernel.shmmni <span style="color:#f92672">=</span> <span style="color:#ae81ff">4096</span>
</span></span><span style="display:flex;"><span>kernel.sem <span style="color:#f92672">=</span> <span style="color:#ae81ff">250</span> <span style="color:#ae81ff">32000</span> <span style="color:#ae81ff">100</span> <span style="color:#ae81ff">128</span>
</span></span><span style="display:flex;"><span>net.ipv4.ip_local_port_range <span style="color:#f92672">=</span> <span style="color:#ae81ff">9000</span> <span style="color:#ae81ff">65500</span>
</span></span><span style="display:flex;"><span>net.core.rmem_default <span style="color:#f92672">=</span> <span style="color:#ae81ff">262144</span>
</span></span><span style="display:flex;"><span>net.core.rmem_max <span style="color:#f92672">=</span> <span style="color:#ae81ff">4194304</span>
</span></span><span style="display:flex;"><span>net.core.wmem_default <span style="color:#f92672">=</span> <span style="color:#ae81ff">262144</span>
</span></span><span style="display:flex;"><span>net.core.wmem_max <span style="color:#f92672">=</span> <span style="color:#ae81ff">1048576</span>
</span></span></code></pre></div><p>/sbin/sysctl -p刷下生效</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-txt" data-lang="txt"><span style="display:flex;"><span>~shmmax=物理内存*80%*80%，单位是字节
</span></span><span style="display:flex;"><span>kernel.shmmax：表示单个共享内存段的最大值，以字节为单位，此值一般为物理内存的一半，不过大一点也没关系，这里设定的为4GB，即“4294967295/1024/1024/1024=4G”。
</span></span><span style="display:flex;"><span>kernel.shmmin：表示单个共享内存段的最小值，默认为1byte
</span></span><span style="display:flex;"><span>kernel.shmall：表示整个系统范围内可用共享内存页的总量，单位是页（page），在32位系统上一页等于4kB，也就是4096字节。计算公式是：shmmax/PAGE_SIZE
</span></span><span style="display:flex;"><span>kernel.shmmni：表示整个系统范围内内存段的最大数量，一般为4096.
</span></span><span style="display:flex;"><span>ip_local_port_range ：表示端口的范围。在监听器帮助客户端进程和服务器进程建立连接时，会用到指定范围内的端口。
</span></span><span style="display:flex;"><span>kernel.sem ：表示设置的信号量，这4个参数内容大小固定。
</span></span><span style="display:flex;"><span>net.core.rmem_default ：表示接收套接字缓冲区大小的缺省值（以字节为单位）。
</span></span><span style="display:flex;"><span>net.core.rmem_max ：表示接收套接字缓冲区大小的最大值（以字节为单位）
</span></span><span style="display:flex;"><span>net.core.wmem_default ：表示发送套接字缓冲区大小的缺省值（以字节为单位）。
</span></span><span style="display:flex;"><span>net.core.wmem_max ：表示发送套接字缓冲区大小的最大值（以字节为单位）。
</span></span></code></pre></div><h2 id="4-开用户">4 开用户</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span><span style="color:#f92672">[</span>root@ywxtdb ~<span style="color:#f92672">]</span><span style="color:#75715e"># groupadd oinstall</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>root@ywxtdb ~<span style="color:#f92672">]</span><span style="color:#75715e"># groupadd dba</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>root@ywxtdb ~<span style="color:#f92672">]</span><span style="color:#75715e"># groupadd asmdba</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>root@ywxtdb ~<span style="color:#f92672">]</span><span style="color:#75715e"># groupadd backupdba</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>root@ywxtdb ~<span style="color:#f92672">]</span><span style="color:#75715e"># groupadd dgdba</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>root@ywxtdb ~<span style="color:#f92672">]</span><span style="color:#75715e"># groupadd kmdba</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>root@ywxtdb ~<span style="color:#f92672">]</span><span style="color:#75715e"># groupadd racdba</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>root@ywxtdb ~<span style="color:#f92672">]</span><span style="color:#75715e"># groupadd oper</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>root@ywxtdb ~<span style="color:#f92672">]</span><span style="color:#75715e"># useradd -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba,racdba,oper -m oracle</span>
</span></span></code></pre></div><p>记得改密码
好像不用太多，只有静默的时候要开这么多个，正常就oinstall和dba,oper就行了。</p>
<h2 id="5-用户环境变量">5 用户环境变量</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>export ORACLE_BASE<span style="color:#f92672">=</span>/home/oracle/app/oracle
</span></span><span style="display:flex;"><span>export ORACLE_HOME<span style="color:#f92672">=</span>/home/oracle/app/oracle/product/19.5.0
</span></span><span style="display:flex;"><span>export PATH<span style="color:#f92672">=</span>$PATH:$ORACLE_HOME/bin:/usr/local/bin
</span></span><span style="display:flex;"><span>export ORACLE_HOSTNAME<span style="color:#f92672">=</span>oracledb
</span></span><span style="display:flex;"><span>export ORACLE_SID<span style="color:#f92672">=</span>orcl
</span></span><span style="display:flex;"><span>export LD_LIBRARY_PATH<span style="color:#f92672">=</span>$ORACLE_HOME/lib:$ORACLE_HOME/rdbms/lib:$ORACLE_HOME/network/lib:/lib:/usr/lib
</span></span><span style="display:flex;"><span>export CLASSPATH<span style="color:#f92672">=</span>$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
</span></span><span style="display:flex;"><span>export NLS_LANG<span style="color:#f92672">=</span>AMERICAN_AMERICA.AL32UTF8
</span></span></code></pre></div><p>自己看着来</p>
<h2 id="6-运包安装">6 运包安装</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>unzip LINUX.X64_193000_db_home.zip -d $ORACLE_HOME
</span></span></code></pre></div><p>用chown -R 更改文件拥有者弄下读写权限就行了
./runInstaller开图形形化</p>
<p>执行完记得用root执行oracle软件下的2个脚本</p>
<p>同时，如果是静默安装参考链接https://blog.csdn.net/bjywxc/article/details/104696121。通过修改conf，和启动参数解决很多问题。</p>
<h2 id="7-起用监听">7 起用监听</h2>
<p>启动监听与DBCA创建数据库不用分先后顺序。只需要执行命令netca然后图形化界面一步步执行。可能要填写sid等之类信息，上网查查找找能找到方法找到。如果出现x11相关错误，xhost +，配置DISPLAY变量解决问题。</p>
<p>监听服务可以通过lsnrctl start/stop/status来查看</p>
<h2 id="8-em">8 EM</h2>
<p>书里不建议你使用EM(Oracle图形化管理)</p>
<h2 id="9-dbca创建数据库">9 DBCA创建数据库</h2>
<p>图形化安装比较简单，装好软件之后运行dbca即可，如果出现x11相关错误，xhost +，配置DISPLAY变量解决问题。</p>
<p>静默安装同上，通过修改conf和启动参数来写。启动安装的网络配置中选择监听程序。如果是静默就要手动填写监听名字。</p>
<h2 id="10-连接数据库">10 连接数据库</h2>
<p>系统认证:sqlplus / as sysdba</p>
<p>我个人比较习惯的用户登录：sqlplus user/passwd@ip:port/service_name</p>
<p>没密码可以不输入，默认端口可以不写</p>
<h2 id="11-启停数据库">11 启停数据库</h2>
<p>通过sqlpuls以sysdba登录数据库，然后跑startup就可以运行了，shutdown关闭。</p>
<h2 id="12-创建用户">12 创建用户</h2>
<p>orcale可以通过默认脚本创建soctt用户，脚本在 path/rdbms/admin里面挺怪的。不是很喜欢。手动创建用户我也mark一下。</p>
<pre tabindex="0"><code>-- DBA 用户执行，默认 users 表空间（不推荐）
create user &lt;username&gt; identified by &lt;password&gt;;

-- 实际开发中
create user &lt;username&gt; identified by &lt;password&gt; 
default tablespace &lt;tablespace_name&gt; -- 默认表空间
temporary tablespace temp -- 临时表空间
quota unlimited on &lt;tablespace_name&gt; -- 表空间额度

grant create session to &lt;username&gt;; -- 授权（可以登录）
</code></pre><p>删除用户，用户权限等自己查询来弄。</p>
    </div>
    <footer class="content__footer"></footer>

            </section>

            <section class="page__aside">
                <div class="aside__about">
<div class="aside__about">
    <img class="about__logo" src="https://juruoxiao.gitee.io/linux_work/images/rice.svg" alt="Logo">
<h1 class="about__title">UxiaoTag</h1>
<p class="about__description">一个蒟蒻无比的萌新.</p>
</div>


<ul class="aside__social-links">
    
    <li>
        <a href="https://github.com/q2516631454" rel="me" aria-label="GitHub" title="GitHub"><i class="fa-brands fa-github" aria-hidden="true"></i></a>&nbsp;
    </li>
    
    <li>
        <a href="mailto:2516631454@qq.com" rel="me" aria-label="Email" title="Email"><i class="fa-solid fa-envelope" aria-hidden="true"></i></a>&nbsp;
    </li>
    
</ul>





<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/sakana-widget@2.5.0/lib/sakana.min.css"
/>
<div id="sakana-widget"></div>
<script>
  function initSakanaWidget() {
    const takina = SakanaWidget.getCharacter('takina');
    takina.initialState = {
      ...takina.initialState,
      i: 0.01,
      d: 1,
    };
    SakanaWidget.registerCharacter('takina-slow', takina);
    new SakanaWidget({ character: 'takina-slow',controls:false}).mount('#sakana-widget');
  }
</script>
<script
  async
  onload="initSakanaWidget()"
  src="https://cdn.jsdelivr.net/npm/sakana-widget@2.5.0/lib/sakana.min.js"
></script>
</div>
                <hr>
                <div class="aside__content">
    <p>orcale单机安装全过程</p>
    
        <p>
            By UxiaoTag, 
            2023-07-17
        </p>
    

                </div>
            </section>

            <footer class="page__footer"><p>
    
    
    
    
    
    
      
    
      
    
    
    
</p>
<br /><br />
<p class="copyright">© 2021–2022 <a href="https://gitee.com/juruoxiao/linux_work">UxiaoTag</a></p>
<p class="advertisement">Powered by <a href="https://gohugo.io/">hugo</a> and <a href="https://github.com/joeroe/risotto">risotto</a>.</p>
</footer>

        </div>
    </body>

</html>
